package com.td.module.farmer.dal.mysql.employ;

import com.td.framework.common.pojo.PageResult;
import com.td.framework.mybatis.core.mapper.BaseMapperX;
import com.td.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.td.module.farmer.controller.admin.employ.vo.EmployExportReqVO;
import com.td.module.farmer.controller.admin.employ.vo.EmployPageReqVO;
import com.td.module.farmer.dal.dataobject.employ.EmployDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 农业社会化服务 Mapper
 *
 * @author 王翔翔
 */
@Mapper
public interface EmployMapper extends BaseMapperX<EmployDO> {

    default PageResult<EmployDO> selectPage(EmployPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<EmployDO>()
                .likeIfPresent(EmployDO::getEmployName, reqVO.getEmployName())
                .eqIfPresent(EmployDO::getEmployType, reqVO.getEmployType())
                .eqIfPresent(EmployDO::getSubject, reqVO.getSubject())
                .betweenIfPresent(EmployDO::getEmployStartTime, reqVO.getEmployStartTime())
                .betweenIfPresent(EmployDO::getEmployEndTime, reqVO.getEmployEndTime())
                .betweenIfPresent(EmployDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(EmployDO::getId));
    }

    default List<EmployDO> selectList(EmployExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<EmployDO>()
                .likeIfPresent(EmployDO::getEmployName, reqVO.getEmployName())
                .eqIfPresent(EmployDO::getEmployType, reqVO.getEmployType())
                .eqIfPresent(EmployDO::getSubject, reqVO.getSubject())
                .betweenIfPresent(EmployDO::getEmployStartTime, reqVO.getEmployStartTime())
                .betweenIfPresent(EmployDO::getEmployEndTime, reqVO.getEmployEndTime())
                .betweenIfPresent(EmployDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(EmployDO::getId));
    }

}
